package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
	zhengzhou "watch_script_state/apps/check_by_zhengzhou"
	"watch_script_state/apps/index"
	"watch_script_state/piugins/plugins_handdler"
)

func main() {
	// 加载相关插件
	Handler.StartPlugins()

	router := gin.Default()
	router.StaticFS("/static", http.Dir("./static"))
	router.StaticFile("/favicon.ico", "/static/favicon.ico")
	router.LoadHTMLGlob("templates/*")

	router.NoRoute(func(c *gin.Context) {
		// 实现内部重定向
		c.HTML(http.StatusOK, "404.html", gin.H{
			"title": "404",
		})
	})

	router.GET("/", index.IndexPage)

	router.Any("/zhengzhou", zhengzhou.IndexPage)

	apiUrlGroup := router.Group("/api")
	{
		apiUrlGroup.GET("/mqtt_protocol", index.MqttProtocolPage)
	}

	println("http://127.0.0.1:9999")
	_ = router.Run(":9999")

}
